package com.jason.bookworm.controller;

import com.jason.bookworm.dao.pojo.Feedback;
import com.jason.bookworm.response.Result;
import com.jason.bookworm.service.HandleFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/feedback")
public class FeedbackController {

    @Autowired
    private HandleFeedbackService handleFeedbackService;

    @GetMapping
    @Secured("reader")
    public Result<List<Feedback>> getAllFeedback() {
        return handleFeedbackService.getAllFeedback();
    }

    @PostMapping
    @Secured("reader")
    public Result<Object> addOneFeedback(@RequestBody Feedback feedback){
        return handleFeedbackService.addOneFeedback(feedback);
    }
}
